package com.tonyodev.fetch2fileserver;

import com.tonyodev.fetch2core.FileResource;
import com.tonyodev.fetch2core.server.FileRequest;

/**
 * Listener that can be attached to a Fetch File Server instance
 * and reports connected clients content file transfer progress.
 */
public interface FetchTransferListener {

    /**
     * Method called to report the start of a file resource transfer to a client.
     *
     * @param sessionId SessionId
     * @param fileRequest File Request
     * @param fileResource file resource being transferred to client
     */
    void onStarted(String sessionId, FileRequest fileRequest, FileResource fileResource);

    /**
     * Method called to report the progress of a file resource transfer to a client.
     *
     * @param sessionId SessionId
     * @param fileRequest File Request
     * @param fileResource file resource being transferred to client
     * @param progress Transfer progress
     */
    void onProgress(String sessionId, FileRequest fileRequest, FileResource fileResource, int progress);

    /**
     * Method called to report the completed file resource transfer to a client.
     *
     * @param sessionId SessionId
     * @param fileRequest File Request
     * @param fileResource file resource being transferred to client
     */
    void onComplete(String sessionId, FileRequest fileRequest, FileResource fileResource);

    /**
     * Method called to report an error that occurred whiles transferring a file resource to client.
     *
     * @param sessionId SessionId
     * @param fileRequest File Request
     * @param fileResource file resource being transferred to client
     * @param throwable error
     */
    void onError(String sessionId, FileRequest fileRequest, FileResource fileResource, Throwable throwable);

}
